package org.cytoscape.myapp.cytoscape_app_v1.internal.tasks.visualHideEdge;

import java.util.List;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyTableUtil;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskMonitor;

public class DeleteVirtualEdgeTask implements Task{
	private CyApplicationManager applicationManager;
	private StateVisualEdge state;
	
	public DeleteVirtualEdgeTask(CyApplicationManager applicationManager,StateVisualEdge state){
		
		this.applicationManager = applicationManager;
		this.state=state;
	}
	@Override
	public void run(TaskMonitor taskMonitor) throws Exception {
		taskMonitor.setTitle("Delete Virtaul Edge");
		taskMonitor.setStatusMessage("Iniciando");
		List<CyEdge> listEdge = CyTableUtil.getEdgesInState(applicationManager.getCurrentNetwork(), "Visible",state.getStateVisibleEdge());
		//	for(CyEdge Edge:listEdge){
		applicationManager.getCurrentNetwork().removeEdges(listEdge);
		applicationManager.getCurrentNetwork().getDefaultEdgeTable().deleteColumn("Visible");
		taskMonitor.setStatusMessage("Finalizado");
	}

	@Override
	public void cancel() {
		// TODO Auto-generated method stub
		
	}

}
